<template>
	<view>
		<view class="u-flex u-row-between u-p-t-30 u-p-b-30" style="border-bottom: 1px solid #f2f2f2;"
			v-for="(item,index) in moiveList" :key="index">
			<view class="u-flex">
				<view class="u-m-r-16">
					<u-image width="180" height="240" :src="item.poster" border-radius="8">
						<view slot="error" class="u-font-24">暂无海报</view>
					</u-image>
				</view>
				<view class="movie-content">
					<view class="u-font-32 u-line-1 u-m-b-8" style="width: 300rpx;">
						{{item.movieName}}
					</view>
					<view class="u-font-28 u-type-info u-m-b-8">
						<text class="score">
							<text class="u-m-r-8">电影评分</text>
							<text v-if="!item.grade">暂无</text>
							<text v-else class="u-type-warning-dark u-font-28">{{item.grade}}</text>
						</text>
					</view>
					<view class="u-font-28 u-type-info u-line-1 u-m-b-8" style="width: 300rpx;">
						导演：{{item.director || '暂无'}}
					</view>
					<view class="u-font-28 u-type-info u-line-1 u-m-b-8" style="width: 300rpx;">
						主演：{{item.cast || '暂无'}}
					</view>
					<view>
						<u-tag text="不退票" class="u-m-r-15" />
						<u-tag text="不改签" />
					</view>
				</view>
			</view>
			<view style="display: flex;">
				<u-button ripple hover-class="none" :custom-style="customStyle" round v-if="item.type==1" @click="toMoiveDetails(item)">购票</u-button>
				<u-button ripple hover-class="none" :custom-style="customStyle2" round style="opacity: 0.5;" v-if="item.type==2" @click="toMoiveDetails(item)">详情</u-button>
			</view>
		</view>
		<view class="u-p-30">
			<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				moiveList: [],
				customStyle: {
					background: 'linear-gradient(to right, #FF6600, #FF9933)',
					color: '#ffffff',
				},
				customStyle2: {
					background: 'linear-gradient(-70deg, #F38D90, #FF6600, #FF9933)',
					color: '#ffffff',
				},

				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '加载更多',
					loading: '努力加载中',
					nomore: '暂无数据'
				},
				type:'',
				name: '',
				size: 10,
				page: 1,
				total: 0
			}
		},
		methods: {
			//获取热映电影列表
			getFilmList() {
				this.status = 'loading';
				this.$u.api.getFilmList({
					name: this.name,
					page: this.page,
					size: this.size,
					type: this.type
				}).then(res => {
					if (res.code == 0) {
						this.moiveList = [...this.moiveList, ...res.data];
						this.total += res.data.length;
						if (this.total >= res.extraInfo) {
							this.status = 'nomore';
						}
					}
				})
			},
			toMoiveDetails(item){
				uni.navigateTo({
					url:'/pages/moive/moiveDetails?movieId='+item.id
				})
			}
		}
	}
</script>

<style>
</style>
